define [ 'fizz' ], (fizz) ->
  class extends fizz.Controller
  
    constructor: () ->
      super()
      @layoutModuleName = 'ioc!appLayout'

    configureMatches: () ->
      @match 'workspaces(/page/:page)', 'list'
      @match 'workspaces/view/:id', 'view'
      @match 'workspaces/add', 'add'
      @match 'workspaces/edit/:id', 'edit'
      @match 'workspaces/delete/:id', 'del'
      
    list: (filter, sort, order, page) ->
      require [ 'ioc!workspaceListView' ], (v) ->
        v.render {
          filter : filter,
          sort : sort,
          order : order,
          page : page
        }

    view: (id) ->
      require [ 'ioc!workspaceCrudView' ], (v) ->
        v.render {
          action : "view",
          id : id
        }

    add: () ->
      require [ 'ioc!workspaceCrudView' ], (v) ->
        v.render {
          action : "add"
        }

    edit: (id) ->
      require [ 'ioc!workspaceCrudView' ], (v) ->
        v.render {
          action : "edit",
          id : id
        }

    del: (id) ->
      require [ 'ioc!workspaceCrudView' ], (v) ->
        v.render {
          action : "delete",
          id : id
        }
